import { getOfficeUse } from '@/static/js/model.js';
export default {
  data() {
    return {
      page: 3,
      list: [],
      noMore: 'noMore'
    }
  },
  methods: {
    //获取办公常用的模板
    getOfficeUseList() {
      getOfficeUse({
        tid: 12,
        page: this.page,
        pagesize: 16,
        s_tid: '',
      }).then(res => {
        if (res.code == 1) {
          let list = res.data;
          if (list.length == 0 || list.length < 16) {
            this.noMore = 'noMore'
          } else {
            this.noMore = 'loadMore'
          }
          this.list.push(...list)
        }
      })
    },

    goDetails(e) {
		uni.showLoading({
			title: '加载中...'
		});
		let aspectRatio = ''
		uni.getImageInfo({
			src: e.images.split('|')[0],
			success: function(res) {
				uni.hideLoading();
				aspectRatio = (res.height / res.width);
				uni.navigateTo({
					url: `/pages/model/modelInfo/index?id=${e.id}&ratio=${aspectRatio}`
				})
			},
			fail: function(error){
				uni.hideLoading();
				uni.showToast({
					title: '加载失败',
					duration: 2000
				});
			}
		});
    },
  },
  onReachBottom() {
    if (this.noMore == 'noMore') return
    this.page++;
    this.getOfficeUseList();
  },
  onShow() {
  },
  onLoad(e) {
    this.getOfficeUseList();
  },
}